package data;

import java.util.List;

import com.rentapark.app.R;
import com.rentapark.app.R.id;
import com.rentapark.app.R.layout;


import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

//this class is an adapter implemented to handle requests list (seen by users that have requested parking spots)
public class ListAdapter extends BaseAdapter implements OnClickListener{
	private Context context;
	private List<ParkingSpot> RequestList;


	public ListAdapter(Context context, List<ParkingSpot> RequestList) {
        this.context = context;
        this.RequestList = RequestList;
    }

	@Override
	public int getCount() {
		return RequestList.size();

	}

	@Override
	public Object getItem(int position) {
		return RequestList.get(position);

	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup viewGroup) {
		ParkingSpot entry = RequestList.get(position);
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.list_row, null);
        }
        //setting all the list's parameters
        TextView address = (TextView) convertView.findViewById(R.id.address);
        address.setText(entry.address);

        TextView tta = (TextView) convertView.findViewById(R.id.tta);
        tta.setText(entry.timeToAvailable);

        TextView priceView = (TextView) convertView.findViewById(R.id.price);
        priceView.setText(Integer.toString(entry.prize));
        
        TextView name = (TextView) convertView.findViewById(R.id.OwnerName);
        name.setText(entry.ownerName);
        
        TextView grade = (TextView) convertView.findViewById(R.id.OwnerGrade);
        grade.setText(Integer.toString(entry.ownerGrade));
        return convertView;
    }


	@Override
	public void onClick(DialogInterface arg0, int arg1) {
		// TODO Auto-generated method stub
		
	}

}
